<%
    def columns=tableDefine.columns
    def pkColumn=tableDefine.getPkColumn();
    def varDomainName=tableNameUtil.lowerCaseFirst(tableDefine.id)
    def urlPrefix=PubUtils.addStrBeforeSeparator(PubUtils.packageToPath(config.category),".")+varDomainName
%>
<template>
    <el-form :model="${PubUtils.toLowerTbNamesCase(tableDefine.dbTableName)}AddForm" :rules="rules" ref="${PubUtils.toLowerTbNamesCase(tableDefine.dbTableName)}AddForm" label-width="120px">
        <%
            columns.each{
                if(pkColumn==it){

                }else{
                    println """<el-form-item label="${it.cnname}" prop="${it.dataName}">""";
                    if(it.jspTag=='TEXT'){
                        println """         <el-input type="text" v-model="${PubUtils.toLowerTbNamesCase(tableDefine.dbTableName)}AddForm.${it.dataName}">

                                            </el-input>""";
                    } else if (it.jspTag=='SELECT'){
                        println """        <elx-select type="text" v-model="${PubUtils.toLowerTbNamesCase(tableDefine.dbTableName)}AddForm.${it.dataName}"
                                                                         selectKey="自己设置"></elx-select>""";
                    } else if (it.jspTag=='TEXTAREA'){
                        println """        <el-input v-model="${PubUtils.toLowerTbNamesCase(tableDefine.dbTableName)}AddForm.${it.dataName}" type="textarea"></el-input>""";
                    } else if (it.jspTag=='EDITOR'){
                        println """        <el-input type="text" v-model="${PubUtils.toLowerTbNamesCase(tableDefine.dbTableName)}AddForm.${it.dataName}">\n
                                               <el-button slot="append" icon="el-icon-search" @click="rateVisible = true"></el-button>\n
                                            </el-input>""";
                    }
                    println "       </el-form-item>";
                }
            }
        %>
    </el-form>
</template>
<script>

    export default {
        name: '${PubUtils.toLowerTbNamesCase(tableDefine.dbTableName)}AddForm',
        props: {},
        data() {
            return {
                ${PubUtils.toLowerTbNamesCase(tableDefine.dbTableName)}AddForm: {},
                rules: {
                    <%
                            cnt=1;
                            columns.each {
                                if (cnt == columns.size()) {
                                    println """    ${it.dataName}: [
                                {required: true, message: '请自己填写', trigger: 'blur'}
                            ]    """;
                                } else {
                                    if (pkColumn == it) {

                                    } else {
                                        println """    ${it.dataName}: [
                                   {required: true, message: '请自己填写', trigger: 'blur'}
                               ],    """;

                                    }

                                cnt++;
                                }
                            }
                        %>
                },





            };
        },
        mounted: function () {
        },
        methods: {
            submitForm() {
                const _this = this;
                <%
                        println 'this.$refs.';
                        print """  ${PubUtils.toLowerTbNamesCase(tableDefine.dbTableName)}AddForm.validate(valid => {
                        if (!valid) {
                            console.log("请检查表单！");
                        } else {  """
                        println 'this.$http.post(';

                    %>
                "/loan/${PubUtils.toLowerTbNamesCase(tableDefine.dbTableName)}Action.do?_md=update${PubUtils.toUpperTbNamesCase(tableDefine.dbTableName)}Selective", _this.${PubUtils.toLowerTbNamesCase(tableDefine.dbTableName)}AddForm)
            .then(function (response) {
                if (response.success) {
                    <%
                                    println '_this.$emit(';
                                    println """  "add${PubUtils.toUpperTbNamesCase(tableDefine.dbTableName)}Dialog");  """;
                                    println '_this.$emit("refreshTable");';
                                    println '_this.$success("修改成功！");';
                                %>
                } else{
                    <%
                                    println '_this.$error(response.msg);';
                                %>
                }
            })
                .catch(function (error) {
                    <%
                                println '_this.$error(error);';
                            %>
                });
    }
    });
    },
    },
    };

</script>
